package Application.StatusBarManager;

import javafx.scene.control.Label;
import javafx.scene.paint.Color;
import javafx.scene.layout.Background;
import javafx.scene.layout.BackgroundFill;

import javax.swing.plaf.TableHeaderUI;

public class StatusBarManager {
    private Label statusBar = null;
    static private StatusBarManager ins = new StatusBarManager();

    public static Color COLOR_WARNING = Color.rgb(217, 214, 15);
    public static Color COLOR_ERROR = Color.rgb(255, 90, 57);
    public static Color COLOR_NORMAL = Color.rgb(59,63,65);
    public static Color COLOR_INFO = Color.rgb(255, 255, 255);

    private StatusBarManager() {

    }

    public static StatusBarManager getInstance() {
        return ins;
    }

    // 注入Label
    public void setStatusBar(Label statusBar) {
        this.statusBar = statusBar;
    }

    // 设置文字颜色
    public void setColor(int r, int g, int b) {
        statusBar.setTextFill(Color.rgb(r, g, b));
    }
    // 设置文字颜色
    public void setColor(Color color) {
        statusBar.setTextFill(color);
    }
    // 设置文本内容
    public void setText(String text) {
        statusBar.setText(text);
////        try{
////            Thread.sleep(5000);
////        }catch (Exception e){
////            e.printStackTrace();
////        }
////        statusBar.setText("...");
//
//        Thread thread = new BackToNormal();
//        thread.start();
//        thread.run();
    }
    // 设置背景颜色
    public void setBackgroundColor(int r, int g, int b) {
        statusBar.setBackground(new Background(new BackgroundFill(Color.rgb(r, g, b), null, null)));
    }
    // 设置背景颜色
    public void setBackgroundColor(Color color) {
        statusBar.setBackground(new Background(new BackgroundFill(color, null, null)));
    }
}
